
/*
 * @Description:
 * @Version: 1.668
 * @Autor: 地虎降天龙
 * @Date: 2025-04-01 10:48:56
 * @LastEditors: 地虎降天龙
 * @LastEditTime: 2025-04-03 20:58:10
 */
import Layout from '@/layout'
function goto(to, from, next, microPath) {
  // 处理路径，确保带上 hash 模式的子应用路径
  const targetPath = to.fullPath.includes('#')
    ? to.fullPath
    : `${to.fullPath}#/${microPath}`
  window.history.replaceState(null, '', targetPath)
  next()
}

const tvtRouter = {
  path: '/TvT.js',
  component: Layout,
  redirect: { name: 'TvTtheBasic' },
  name: 'TvT.js',
  meta: {
    title: '嵌入TvT.js子系统',
    icon: 'el-icon-ice-cream-round'
  },
  children: [
    {
      path: 'theBasic',
      component: () => import('@/views/Micro/tvt'),
      name: 'TvTtheBasic',
      meta: { title: '简单实例', icon: 'el-icon-check', noCache: false, isMicro: true, microPath: 'plugins/qiankunTvt/theBasic' },
      beforeEnter: (to, from, next) => { goto(to, from, next, 'plugins/qiankunTvt/theBasic') }
    },
    {
      path: 'events',
      component: () => import('@/views/Micro/tvt'),
      name: 'TvTevents',
      meta: { title: '通讯实例', icon: 'el-icon-loading', noCache: false, isMicro: true, microPath: 'plugins/qiankunTvt/events' },
      beforeEnter: (to, from, next) => { goto(to, from, next, 'plugins/qiankunTvt/events') },
      props: { showButton: true }
    },
    {
      path: 'other',
      component: () => import('@/views/Micro/tvt'),
      name: 'TvTother',
      meta: { title: '其他场景移植', icon: 'international', noCache: false, isMicro: true, microPath: 'plugins/qiankunTvt/other' },
      beforeEnter: (to, from, next) => { goto(to, from, next, 'plugins/qiankunTvt/other') }
    }
  ]
}

export default tvtRouter
